<template>
	<app-page>
		<wd-config-provider :theme="theme">
			<view class="container">
				<view class="list">
					<view class="item" @click="bank(item)" v-for="(item, index) in dataList"
						:style="{'background-color':item.bank_back_color}">
						<view class="item-icon">
							<image :src="item.bank_img"></image>
							<!-- <text :class="['iconfont','icon-jianhang']"></text> -->
						</view>
						<view class="item-bg">
							<!-- <text :class="['iconfont','icon-jianhang']"></text> -->
							<image :src="item.bank_img"></image>
						</view>
						<view class="item-text">
							<view>
								{{ item.bank_name }}
							</view>
							<view>
								{{ item.real_name }}
							</view>
							<view>
								{{ item.card_no }}
							</view>
						</view>
					</view>
				</view>
				<view class="add-bank-card" @click="doAdd">
					<view class="icon">
						<text class="iconfont icon-jiahao"></text>
					</view>
					<view class="text">
						添加银行卡
					</view>
				</view>
			</view>
		</wd-config-provider>
	</app-page>
</template>

<script lang="ts">
	import {
		defineComponent, ref, nextTick,
		getCurrentInstance
	} from 'vue';

	import { onShow, onLoad } from '@dcloudio/uni-app';
	import { getBankGetList } from "@/api/index.ts"
	import useDataLoad from '@/hooks/useDataLoad';

	import useRouter from "@/hooks/useRouter"

	export default defineComponent({
		name: '',
		components: {},
		setup(props, ctx) {
			const router = useRouter();
			// 日间light、夜间dark主题
			const theme = ref('light');


			const dataLoad = useDataLoad(getBankGetList);
			let instance = null;
			onShow(() => {
				dataLoad.getData();
			})
			onLoad(() => {
				instance = getCurrentInstance();
			})
			const bank = async (item : any) => {
				if (instance) {
					const eventChannel = instance.proxy.getOpenerEventChannel();
					eventChannel.emit('getBank', item);
				}

			}
			const doAdd = () => {
				router.push("/purse/add/add");
			}
			return {
				theme,
				bank,
				doAdd,
				...dataLoad,
			};
		}
	});
</script>
<!-- #ifdef MP-WEIXIN -->
<style lang="less">
	page {
		background-color: #f2f2f2;
	}
</style>
<!-- #endif -->
<style lang="less" scoped>
	page {
		background-color: #f2f2f2;
	}

	.container {
		padding: 24rpx;

		.list {
			.item {
				box-shadow: 0rpx 0rpx 9rpx 0rpx rgba(209, 209, 209, 0.28);
				border-radius: 10rpx;
				color: #FFF;
				padding: 24rpx;
				display: flex;
				align-items: flex-start;
				position: relative;
				margin-bottom: 24rpx;
				overflow: hidden;

				.item-icon {
					width: 40rpx;
					height: 40rpx;
					padding-right: 20rpx;

					image {
						width: 100%;
						height: 100%;
					}
				}

				.item-bg {
					position: absolute;
					right: 15rpx;
					top: -10rpx;

					image {
						opacity: 0.42;
						width: 220rpx;
						height: 220rpx;
					}


				}

				.item-text {
					>view:nth-child(1) {
						font-family: PingFang;
						font-weight: 400;
						font-size: 25rpx;
						color: #FFFFFF;
					}

					>view:nth-child(2) {
						font-family: PingFang;
						font-weight: 400;
						font-size: 17rpx;
						color: #FFFFFF;
						opacity: 0.8;
						margin: 10rpx 0 30rpx;
					}

					>view:nth-child(2) {
						font-family: PingFang;
						font-weight: 400;
						font-size: 24rpx;
						color: #FFFFFF;
					}
				}
			}
		}

		.add-bank-card {
			padding: 24rpx;
			height: 147rpx;
			background: #FFFFFF;
			box-shadow: 0rpx 0rpx 9rpx 0rpx rgba(209, 209, 209, 0.28);
			border-radius: 10rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			flex-direction: column;

			.icon {
				.iconfont {
					font-size: 66rpx;
					color: #999999;
				}
			}

			.text {
				font-weight: 400;
				font-size: 17rpx;
				color: #999999;
				margin-top: 30rpx;
			}
		}
	}
</style>